import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

public class ArrayListListInterface {
    public static void main(String[] args) {
        List<String> list = new ArrayList<>();

        list.add(0,"a");
        list.add(0,"b");
        list.add(0,"c");

        List<String> collection = new ArrayList<>();
        collection.add("x");
        collection.add("y");
        collection.add("z");


        list.addAll(0, collection);

        String res = list.get(2);
        System.out.println("res = " + res);

        int indexOf = list.indexOf("z");
        System.out.println("indexOf = " + indexOf);

        int lastIndexOf = list.lastIndexOf("b");
        System.out.println("lastIndexOf = " + lastIndexOf);

        String remove = list.remove(1);
        System.out.println("remove = " + remove);

        String test = list.set(0, "test");
        System.out.println("test = " + test);

        List<String> stringList = list.subList(0, 3);

        for (String s : list) {
            System.out.println(s);
        }

        Iterator<String> iterator = stringList.iterator();
        while (iterator.hasNext()) {
            iterator.next();
        }

    }
}
